package com.sx.jys.ui.act

import android.content.Intent
import android.os.Bundle
import androidx.lifecycle.viewModelScope
import com.sx.jys.app.framework.BaseActivity
import com.sx.jys.app.until.CacheUntil
import com.sx.jys.databinding.ActWelcomeBinding
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import me.hgj.jetpackmvvm.base.viewmodel.BaseViewModel

class WelcomeAct : BaseActivity<BaseViewModel, ActWelcomeBinding>() {
    override fun initView(savedInstanceState: Bundle?) {
        getImmersionBar().init()
    }

    override fun initData() {
        mViewModel.viewModelScope.launch {
            delay(800)
            if (CacheUntil.isLogin()) {
                startActivity(Intent(this@WelcomeAct, MainAct::class.java))
            } else {
                startActivity(Intent(this@WelcomeAct, LoginAct::class.java))
            }
            finish()
        }
    }
}